package cn.maxwell._01_oneway;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

/**
 * 单向消息生产者
 */
public class Producer {
    public static void main(String[] args) throws Exception {
        //1.创建生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("oneway-producer-group");
        //2.配置namesrv地址
        producer.setNamesrvAddr("localhost:9876");
        //3.开启生产者实例
        producer.start();
        //4.设置消息
        Message message = new Message("oneway", "maxwell", "江糖".getBytes(StandardCharsets.UTF_8));
        //5.发送消息
        producer.sendOneway(message);
        //6.关闭
        producer.shutdown();
    }
}
